/**
 * 
 */
package com.pmsco.pms.core.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.pmsco.pms.core.dao.PmsPermissionDao;
import com.pmsco.pms.core.domain.PmsPermission;

/**
 * @author Tran Thanh Long
 *
 */
public class PmsPermissionDaoImpl extends HibernateDaoSupport implements PmsPermissionDao {

	public PmsPermission getPermissionById(Long id) {
		PmsPermission ret = getHibernateTemplate().load(PmsPermission.class, id);
		return ret;
	}

	public PmsPermission getPermissionByName(String name) {
		PmsPermission searchTemplate = new PmsPermission();
		searchTemplate.setPermission(name);
		PmsPermission ret = null;
		List<PmsPermission> temp = new ArrayList<PmsPermission>();
		temp = getHibernateTemplate().findByExample(searchTemplate);
		if(temp != null && temp.size() == 1)
			ret = temp.get(0);
		return ret; 
	}

}
